local feici = fk.CreateSkill{
  name = "lingling__feici",
}

Fk:loadTranslationTable{
  ["lingling__feici"] = "飞词",
  [":lingling__feici"] = "每回合限两次，当你使用或打出牌后，你可以弃置一至两张牌，然后若有角色手牌恰好比你多一张，你摸两张牌。",

  ["#lingling__feici-invoke"] = "飞词：你可以弃一至两张牌，若有角色手牌比你恰好多一张则摸两张牌",
}

feici:addEffect(fk.CardUseFinished, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(feici.name) and
      not player:isNude() and player:usedSkillTimes(feici.name, Player.HistoryTurn) < 2
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local cards = room:askToDiscard(player, {
      min_num = 1,
      max_num = 2,
      include_equip = true,
      skill_name = feici.name,
      prompt = "#lingling__feici-invoke",
      cancelable = true,
      skip = true,
    })
    if #cards > 0 then
      event:setCostData(self, {cards = cards})
      return true
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    room:throwCard(event:getCostData(self).cards, feici.name, player, player)
    if player.dead then return end
    if table.find(room.alive_players, function (p)
      return p:getHandcardNum() - player:getHandcardNum() == 1
    end) then
      player:drawCards(2, feici.name)
    end
  end,
})

return feici
